Imports System.Data.SqlClient
Public Class Experience

    Public Shared Function GetExperience() As DataTable


        Try
            str = " SELECT EXPERIENCE_ID,Name=ENGLISH_NAME +' ( '+KHMER_NAME+' )',COMPANY_NAME,DURATION,EMPLOYEE_POSITION,SALARY,JOB_DESCRIPTION,NOTE,START_DATE,END_DATE,ACTIVE FROM  VIEW_EXPERIENCE  WHERE ACTIVE=1 ORDER BY EXPERIENCE_ID ASC "

            Dim dataAdapter As SqlDataAdapter
            dataAdapter = New SqlDataAdapter(str, CType(Dbinterface.Connection, SqlConnection))
            Dim dataTable As DataTable = New DataTable()
            dataAdapter.Fill(dataTable)
            Return dataTable
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
            Return Nothing
        End Try
    End Function
     
    Public Shared Sub AddExperience(ByVal exp As ExperinceInfo)


        CmdPro.Begin()

        Try



            CmdPro.Parameters("@employeeId") = exp.EmployeeId
            CmdPro.Parameters("@companyName") = exp.CompanyName
            CmdPro.Parameters("@duration") = exp.Duration
            CmdPro.Parameters("@employeePosition") = exp.EmployeePosition
            CmdPro.Parameters("@salary") = exp.Salary
            CmdPro.Parameters("@jobDescription") = exp.JobDescription
            CmdPro.Parameters("@note") = exp.Note
            CmdPro.Parameters("@startDate") = exp.StartDate
            CmdPro.Parameters("@endDate") = exp.EndDate
            CmdPro.Parameters("@active") = exp.Active
            exp.ExperinceId = CmdPro.ExecuteNonQuery("InsertExperience", "@id")
            CmdPro.Commit()


        Catch ex As Exception


            CmdPro.Rollback()


            MsgBox(ex.Message)


        End Try


    End Sub

    Public Shared Sub UpdateExperience(ByVal exp As ExperinceInfo)


        CmdPro.Begin()

        Try


            CmdPro.Parameters("@id") = exp.ExperinceId
            CmdPro.Parameters("@employeeId") = exp.EmployeeId
            CmdPro.Parameters("@companyName") = exp.CompanyName
            CmdPro.Parameters("@duration") = exp.Duration
            CmdPro.Parameters("@employeePosition") = exp.EmployeePosition
            CmdPro.Parameters("@salary") = exp.Salary
            CmdPro.Parameters("@jobDescription") = exp.JobDescription
            CmdPro.Parameters("@note") = exp.Note
            CmdPro.Parameters("@startDate") = exp.StartDate
            CmdPro.Parameters("@endDate") = exp.EndDate
            CmdPro.Parameters("@active") = exp.Active
            exp.ExperinceId = CmdPro.ExecuteNonQuery("UpdateExperience")
            CmdPro.Commit()


        Catch ex As Exception


            CmdPro.Rollback()


            MsgBox(ex.Message)


        End Try


    End Sub
    Public Shared Sub DeleteExperience(ByVal Exper As ExperinceInfo)
        CmdPro.Begin()
        Try
            CmdPro.Parameters("@id") = Exper.ExperinceId
            CmdPro.ExecuteNonQuery("DeleteExperience")
            CmdPro.Commit()
        Catch ex As Exception
            CmdPro.Rollback()
            MsgBox(ex.Message)
        End Try
    End Sub

End Class